<template>
  <div>
    <table>
      <tr>
        <td>年级</td>
        <td>课程</td>
      </tr>
      <tr v-for="i in classlist">
        <td>{{ i.name }}</td>
        <td v-for="j in i.banji">{{ j.name }}</td>
      </tr>
    </table>
    <p>姓名：<input type="text" v-model="form.name"></p>
    <p>账号：<input type="text" v-model="form.username"></p>
    <p>密码：<input type="text" v-model="form.password"></p>
    <p>年级：<select name="" id="" v-model="form.cla">
      <option :value="i.types" v-for="i in classlist">{{ i.name }}</option>

    </select>
    </p>
    <button @click="regi">
      注册
    </button>
    <router-link :to="{name:'xpy_login'}">登录</router-link>
  </div>
</template>

<script>
export default {
  name: "show_class",
  data() {
    return {
      classlist: [],
      banjilist: [],
      form: {}
    }
  },
  methods: {
    get_class() {
      this.$axios.get('users/class/')
        .then(res => {
          this.classlist = res.data.list
        })
    },
    regi() {
      this.$axios.post('users/class/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('注册成功')
            this.form = {}
          } else {
            alert('注册失败')
          }
        })
    }

  },
  mounted() {
    this.get_class()

  }
}
</script>

<style scoped>

</style>
